<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>单位</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: blueviolet;
            color: white;
        }

        /* 相对于父元素的百分比 */
        .div2 {
            width: 50%;
            height: 50%;
            background-color: red;
            color: white;
        }
    </style>
</head>

<body>
    <div>
        <div class="div2"></div>
    </div>
</body>

</html>